package top.ezzz.tool;

import java.io.*;
import java.util.regex.Pattern;

public class TextUtil {

    public static void removeSpecial(String inputFilePath, String outputFilePath) throws IOException {
        // 定义正则表达式，匹配常用字符
        String regex = "[^\\u4e00-\\u9fa5a-zA-Z0-9，。！？：；、,.!?;: ]";
        Pattern pattern = Pattern.compile(regex);

        BufferedReader reader = new BufferedReader(new FileReader(inputFilePath));
        BufferedWriter writer = new BufferedWriter(new FileWriter(outputFilePath));

        String line;
        while ((line = reader.readLine()) != null) {
            // 替换特殊字符
            String cleanedLine = pattern.matcher(line).replaceAll("");
            writer.write(cleanedLine);
            writer.newLine();
        }
    }

}
